package com.duobaoyu.dby.supply.biz.client.boundary.message.bean.pojo;

import com.duobaoyu.dby.channel.adapter.annotation.ChannelMapping;
import com.duobaoyu.dby.channel.adapter.enums.BizMessageTypeEnum;
import com.duobaoyu.dby.channel.adapter.enums.MessageOperationalCodeTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName MessagePayload
 * @createTime 16:44:00 2023/09/27
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MessagePayload {
	/**
	 * 是否批量消息 true - 是 ； false - 否
	 */
	private Boolean isBatch;

	/**
	 * 消息体
	 */
	private List<ChannelMessage> channelMessages;

	@Data
	@Builder
	@NoArgsConstructor
	@AllArgsConstructor
	public static class ChannelMessage {
		/**
		 * 消息id
		 */
		private Long messageId;
		/**
		 * 渠道编号
		 */
		private String channelCode;
		/**
		 * 渠道配置Key
		 */
		private String configUniqueKey;
		/**
		 * 渠道原消息体
		 * 经过com.duobaoyu.dby.channel.adapter.util.DeflaterUtils#zipString(java.lang.String) 方法压缩过的Base64字符串
		 * DeflaterUtils.zipString(JSON.toJSONString(message))
		 */
		private String originalMessage;
		/**
		 * 唯一key
		 * DigestUtils.md5Hex(JSON.toJSONString(message))
		 */
		private String uniqueKey;
		/**
		 * 消息类型
		 *
		 * @see BizMessageTypeEnum
		 */
		private Integer messageType;
		/**
		 * 来源Class
		 */
		private String sourceClass;
		/**
		 * 操作编号，订单编号、商品编号、售后编号
		 */
		@ChannelMapping(operationalCodeType = MessageOperationalCodeTypeEnum.BUSINESS)
		private String operationalCode;
		/**
		 * 渠道操作编号，渠道订单编号、渠道商品编号、渠道售后编号
		 */
		@ChannelMapping(operationalCodeType = MessageOperationalCodeTypeEnum.CHANNEL)
		private String channelOperationalCode;
		/**
		 * 是否是批量消息
		 */
		private Boolean isBatch;
		/**
		 * 渠道原消息体转化后的统一的业务消息体
		 */
		private Object data;
	}
}
